//
//  FlutterPlugin.swift
//  Runner
//
//  Created by szb on 2023/6/19.
//

import Foundation
import Flutter
import SVProgressHUD

class FlutterMethodPlugin: NSObject, FlutterPlugin {
   // 实现注册函数
    static func register(with registrar: FlutterPluginRegistrar) {
        // 方法的通道
        let channel = FlutterMethodChannel(name: "qds_channel", binaryMessenger: registrar.messenger())
        // 创建类对象
        let plugin = FlutterMethodPlugin()
        // 添加注册
        registrar.addMethodCallDelegate(plugin, channel: channel)
    }

    func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
        if (call.method == "showHudWithMsg") {
            let msg = call.arguments as! String;
            SVProgressHUD.showInfo(withStatus: msg);
        }
        if (call.method == "tablevc") {
            let vc = QdsTableVC(style: .grouped)
            let nav = UIApplication.shared.keyWindow?.rootViewController as? UIViewController
            nav?.present(vc, animated: true)
        }
        if (call.method == "collectvc") {
            let vc = QdsCollectVC()
            let nav = UIApplication.shared.keyWindow?.rootViewController as? UIViewController
            nav?.present(vc, animated: true)
        }
    }
   
}
